home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 011 / setdir2.arc / SETDIR.DOC < prev    next >
Encoding:
Text File  |  1986-12-08  |  2.5 KB  |  72 lines

  1. SETDIR   -  Use to restore the current directory
  2.  
  3. Requires DOS 2.0 or above and 2048 bytes of disk and memory space (not resident 
  4. when not in use).
  5.  
  6.  
  7.                  Copyright 1986, Arnold B. Krueger GPW MI 48236
  8.                       (ARNY KRUEGER @EXEC-PC 414-964-5160)
  9.                   Permission for free use and distribution by
  10.                   interested parties, not for profit, granted.
  11.  
  12. SETDIR sets the environment string 'CURDIR' with the current directory. Once 
  13. this has been done it is very simple to restore the current directory after it 
  14. has been changed by some other program. To restore the current directory, once 
  15. saved by SETDIR, simply issue the following command: 
  16.   
  17.                   CD %CURDIR%
  18.  
  19. This technique has distinct advantages over other techniques that create files 
  20. (CD >CURDIR.FIL) or modify the interupt vector (PUSHDIR/POPDIR from PC magazine 
  21. and/or PC OUTLINE). It is much faster, creates no files, cannot be impacted by 
  22. programs that modify the interrupt vector, and requires only one very small 
  23. (<512 byte) program. Paraphrasing Uncle Lee Iacocca: "If there is a better 
  24. program, use it!" 
  25.  
  26. If you desire setting an environment variable other than CURDIR, use the 
  27. following: 
  28.  
  29.                  SETDIR  name
  30.  
  31. The environment variable "name" will be set to the current directory. 
  32.  
  33. Example:
  34.  
  35.     In my batch file, I want to change directory to directory \$TEMP,
  36. edit a file named FUN.FIL, and then return to the current directory:
  37.  
  38.               Echo off
  39.               b:setdir oldir
  40.               cd \$temp
  41.               ed fun.fil
  42.               cd %oldir%
  43.  
  44. This file is included as: TEST.BAT, and assumes that: SETDIR is on the B disk,
  45. and a subdirectory named \$temp exists on the curent disk.
  46.  
  47. Note that SETDIR DOES NOT CHANGE THE CURRENT DIRECTORY. You must do this via 
  48. the CD command. All SETDIR does is put the name of the current directory where 
  49. it is accessible to the batch language.  
  50.  
  51.  
  52. Since the PATH is in the environment string, a similar procedure can be used to 
  53. save it:
  54.                      SET SAVPATH=%PATH%
  55.                        .
  56.                        .
  57.                        .
  58.  
  59.                      PATH %SAVPATH%
  60.  
  61.  
  62.  
  63. ERRORLEVEL setting by this program:
  64.  
  65. Note that due to limitations in DOS, the errorlevel can be 0 even if
  66. SETDIR fails due to lack of environment space. Errorlevels 1 and 2
  67. are for SETDIR detected errors. Errorlevel=1 means the DOS release is not at 
  68. least 2. Errorlevel=2 means that the directory string was too long to return. 
  69.  
  70. 
  71.  
  72.